package com.ellecity06.cwhiskymall.adapter

import android.content.Context
import android.view.LayoutInflater
import android.view.ViewGroup
import androidx.recyclerview.widget.RecyclerView
import com.chad.library.adapter.base.BaseQuickAdapter
import com.ellecity06.common.ktx.load
import com.ellecity06.common.viewholder.ViewBindingHolder
import com.ellecity06.cwhiskymall.bean.response.AppMenuSettingRespone
import com.ellecity06.cwhiskymall.bean.response.ClassifyChildren
import com.ellecity06.cwhiskymall.bean.response.ClassifyResponse
import com.ellecity06.cwhiskymall.databinding.ItemClassifyLeftBinding
import com.ellecity06.cwhiskymall.databinding.ItemClassifyTopBinding
import com.ellecity06.cwhiskymall.databinding.ItemHomeCategoryBinding

/**
 * @author joe
 * @time
 * @des 分类左边
 */
class ClassifyLeftAdapter :
    BaseQuickAdapter<ClassifyChildren, ViewBindingHolder<ItemClassifyLeftBinding>>() {
    var pos = 0
    override fun onBindViewHolder(
        holder: ViewBindingHolder<ItemClassifyLeftBinding>,
        position: Int,
        item: ClassifyChildren?
    ) {
        holder.binding.tvLeft.text = item?.categoryName
        holder.binding.tvLeft.isSelected = pos == position
    }

    override fun onCreateViewHolder(context: Context, parent: ViewGroup, viewType: Int): ViewBindingHolder<ItemClassifyLeftBinding> {
        val view = ItemClassifyLeftBinding.inflate(LayoutInflater.from(context), parent, false)
        return ViewBindingHolder(view)
    }

    fun notifyPos(pos: Int) {
        this.pos = pos
        notifyDataSetChanged()
    }
}